package com.itcam.jyuoop;

import java.util.Random;

public class LevelExerciseGenerator implements ExerciseGenerator {
    Level level;

    public LevelExerciseGenerator(Level level) {
        this.level = level;
    }

    @Override
    public void generate(Equation equation) {
        // 根据级别生成算式的逻辑
        Random random = new Random();
        double firstOp = level.minValue + (level.maxValue - level.minValue) * random.nextDouble();
        double secondOp = level.minValue + (level.maxValue - level.minValue) * random.nextDouble();
        char operator = level.operators[random.nextInt(level.operators.length)];

        equation.firstOp = firstOp;
        equation.secondOp = secondOp;
        equation.operator = operator;
    }
}